# frozen_string_literal: true

FactoryBot.define do
  factory :vs_advisory, class: '::Gitlab::VulnerabilityScanning::Advisory' do
    xid { SecureRandom.uuid }
    title { FFaker::Lorem.sentence }
    description { FFaker::Lorem.paragraph }
    solution { FFaker::Lorem.paragraph }

    identifiers do
      [
        association(:pm_identifier, :cve),
        association(:pm_identifier, :gemnasium)
      ]
    end

    urls { Array.new(2) { FFaker::Internet.uri("https") } }
    cvss_v2 { "AV:N/AC:M/Au:N/C:N/I:P/A:N" }
    cvss_v3 { "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:N/I:L/A:L" }
    affected_component { association :vs_affected_component }

    skip_create

    initialize_with do
      Gitlab::VulnerabilityScanning::Advisory.new(
        xid: xid,
        title: title,
        description: description,
        solution: solution,
        identifiers: identifiers,
        urls: urls,
        cvss_v2: cvss_v2,
        cvss_v3: cvss_v3,
        affected_component: affected_component
      )
    end
  end
end
